<template>
  <div>
    <search-header></search-header>
    <div class="search-item">
      <div class="input-part">
        <span class="iconfont search-icon">&#xe63c;</span>
        <input ref="searchWord" v-model="searchWord" type="text" />
      </div>
      <div class="btn" @click="handleSearchClick">搜索</div>
    </div>
    <div class="list">
      <div class="title">搜索历史</div>
      <div class="content">
        <div class="item">游乐园</div>
        <div class="item">动物园</div>
        <div class="item">爬山</div>
        <div class="item">漂流漂流漂流</div>
        <div class="item">动物园</div>
        <div class="item">动物园</div>
      </div>
    </div>
    <div class="list">
      <div class="title">热门搜索</div>
      <div class="content">
        <div class="item">游乐园</div>
        <div class="item">动物园</div>
        <div class="item">爬山</div>
        <div class="item">漂流漂流漂流</div>
        <div class="item">动物园</div>
        <div class="item">动物园</div>
      </div>
    </div>
  </div>
</template>

<script>
import SearchHeader from './components/Header'
export default {
  name: 'Search',
  data () {
    return {
      searchWord: ''
    }
  },
  components: {
    SearchHeader
  },
  methods: {
    handleSearchClick () {
      this.$router.push({
        path: '/productList',
        query: {
          searchWord: this.searchWord
        }
      })
    }
  },
  mounted () {
    console.log(this.$refs['searchWord'])
    this.$refs['searchWord'].focus()
  }
}
</script>

<style lang="stylus" scoped>
  @import '~styles/varibles.styl'
  .search-item
    display flex
    align-items center
    padding: 0 .24rem
    height 1rem
    border-bottom .16rem solid #eee
    .input-part
      flex 1
      padding 0 .24rem
      border 1px solid #eee
      height .6rem
      display flex
      align-items center
      border-radius .3rem
      background #f8f8f8
      .search-icon
        margin-right .16rem
        color $bgColor
        font-size .4rem
      input
        display block
        flex 1
        background inherit
    .btn
      padding .06rem 0.1rem .06rem 0.34rem
      color $bgColor
  .list
    margin 0 .24rem .16rem
    border-bottom 1px dashed #eee
    .title
      padding .24rem 0
      color: #666
      font-weight 500
    .content
      margin-top .1rem
      margin-bottom .1rem
      display flex
      flex-wrap wrap
      .item
        margin-right .16rem
        margin-bottom .16rem
        padding .08rem .16rem
        border 1px solid #eee
        border-radius .06rem
</style>
